import time

import keyboard

import  func

def tableSetting():
    func.rightClick()
    func.keypress("r")
    func.leftClick(x=689, y=483)
    func.leftClick(x=454, y=96)
    func.leftClick(x=458, y=148)
    func.leftClick(x=743, y=225)
    func.leftClick(x=735, y=299)
    func.leftClick(x=659, y=372)
    func.leftClick(x=618, y=471)
    func.leftClick(x=611, y=94)
    func.leftClick(x=556, y=154)
    func.leftClick(x=515, y=359)
    func.leftClick(x=798, y=501)
    func.leftClick(x=721, y=526)

def titleSetting():
    func.rightClick()
    func.keypress("r")
    func.leftClick(x=679, y=483)
    func.leftClick(x=462, y=94)
    func.leftClick(x=733, y=292)
    func.leftClick(x=630, y=368)
    func.leftClick(x=611, y=443)
    func.leftClick(x=800, y=501)
    func.leftClick(x=736, y=527)


def startFunc(func):
    '''
    按下 f10 起动
    按下 esc 结束
    :param func:
    :return:
    '''
    print("=====================\n")
    print("按下 [f10] 起动")
    print("按下 [esc] 退出")
    print("=====================\n")
    try:
        while True:
            if keyboard.is_pressed("f10"):
                func()
                # 等待按键释放避免重复触发
                while keyboard.is_pressed("f10"):
                    time.sleep(0.1)

            if keyboard.is_pressed("esc"):
                break

            time.sleep(0.05)  # 降低CPU占用
    except :
        pass



if __name__ == "__main__":
#     # tableSetting()
    startFunc(titleSetting)
